from typing import Any

from django.views.generic import DetailView, ListView
from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView, UpdateView

from .forms import FeedbackForm
from .models import Feedback


class FeedbackView(CreateView):
    model = Feedback
    form_class = FeedbackForm
    template_name = "feedback/feedback.html"
    success_url = "/done"


class FeedBackViewUpdate(UpdateView):
    model = Feedback
    form_class = FeedbackForm
    template_name = "feedback/feedback.html"
    success_url = "/done"


class DoneView(TemplateView):
    template_name = "feedback/done.html"

    def get_context_data(self, **kwargs) -> dict[str, Any]:  # noqa: ANN003
        context = super().get_context_data(**kwargs)
        context["name"] = "Ivanov I.I."
        context["date"] = "01.01.2019"
        return context


class ListFeedBack(ListView):
    template_name = "feedback/list_feedback.html"

    model = Feedback
    context_object_name = "feedbacks"

    def get_queryset(self):  # noqa: ANN201
        queryset = super().get_queryset()
        return queryset.filter(rating__gt=1)


class DetailFeedBack(DetailView):
    template_name = "feedback/detail_feedback.html"
    model = Feedback
